package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.EngineerPlanEffort;
import com.shrcl.engineerprocess.domain.EngineerProjectPlan;
import com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl;
import com.shrcl.engineerprocess.domain.impl.EngineerProjectPlanImpl;
import com.shrcl.engineerprocess.domain.proxy.EngineerPlanEffortProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("ENGINEERPLANEFFORT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "engineerplaneffort")
public class EngineerPlanEffortImpl extends BaseModelObject implements EngineerPlanEffort {
  public EngineerPlanEffortImpl() {
    super();
  }
  
  public EngineerPlanEffortImpl(final EngineerProjectPlan engineerProjectPlan) {
    super();
    this.engineerProjectPlan = engineerProjectPlan;
  }
  
  @JoinColumn(name = "engineerProjectPlan_id")
  @ManyToOne(targetEntity = EngineerProjectPlanImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerProjectPlan engineerProjectPlan;
  
  public EngineerProjectPlan getEngineerProjectPlan() {
    return this.engineerProjectPlan;
  }
  
  public EngineerPlanEffort setEngineerProjectPlan(final EngineerProjectPlan engineerProjectPlan) {
    this.engineerProjectPlan = engineerProjectPlan;
    return this;			
    
  }
  
  @JoinColumn(name = "engineerLevel_id")
  @ManyToOne(targetEntity = EngineerLevelImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerLevel engineerLevel;
  
  public EngineerLevel getEngineerLevel() {
    return this.engineerLevel;
  }
  
  public EngineerPlanEffort setEngineerLevel(final EngineerLevel engineerLevel) {
    this.engineerLevel = engineerLevel;
    return this;			
    
  }
  
  private Integer manCount;
  
  public Integer getManCount() {
    return this.manCount;
  }
  
  public EngineerPlanEffort setManCount(final Integer manCount) {
    this.manCount = manCount;
    return this;			
    
  }
  
  public static EngineerPlanEffort create(final EngineerProjectPlan engineerProjectPlan, final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.EngineerPlanEffort engineerPlanEffort = new com.shrcl.engineerprocess.domain.impl.EngineerPlanEffortImpl(
    	engineerProjectPlan
    );
    objectFactory.create(engineerPlanEffort);
    return engineerPlanEffort;			
    
  }
  
  public static EngineerPlanEffort createEngineerPlanEffortImpl(final EngineerProjectPlan engineerProjectPlan, final IObjectFactory objectFactory, final Procedure1<EngineerPlanEffort> init) {
    com.shrcl.engineerprocess.domain.EngineerPlanEffort engineerPlanEffort = new com.shrcl.engineerprocess.domain.impl.EngineerPlanEffortImpl(
    	engineerProjectPlan
    );
    objectFactory.create(engineerPlanEffort);
    init.apply(engineerPlanEffort);
    
    return engineerPlanEffort;			
    
  }
  
  public EngineerPlanEffortProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.EngineerPlanEffortProxy proxy = new com.shrcl.engineerprocess.domain.proxy.EngineerPlanEffortProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
